<!DOCTYPE html>
<html>
<head>
<title>navigator.network.connection.type Example</title>

<script type="text/javascript" charset="utf-8" src="jquery-1.8.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8">

    // Wait for Cordova to load
    // 
    document.addEventListener("deviceready", onDeviceReady, false);

    // Cordova is loaded and it is now safe to make calls Cordova methods
    //
    function onDeviceReady() {
        checkConnection();
    }

    function checkConnection() {
        var networkState = navigator.network.connection.type;

        var states = {};
        states[Connection.UNKNOWN]  = 'Unknown connection';
        states[Connection.ETHERNET] = 'Ethernet connection';
        states[Connection.WIFI]     = 'WiFi connection';
        states[Connection.CELL_2G]  = 'Cell 2G connection';
        states[Connection.CELL_3G]  = 'Cell 3G connection';
        states[Connection.CELL_4G]  = 'Cell 4G connection';
        states[Connection.NONE]     = 'No network connection';
// alert('Connection type: ' + states[networkState]+data);
		
		
    }
 
	$.get("http://10.43.29.211:8080/testserver/RegServlet", function(data) {
		//$("msg").innerHTML = "<font color='red' size='2' >"+data+"</font>";

		if ($.trim(data) == $.trim("abc")) {
			$("#msg").html(
					"<font color='green' size='2' >" + data + ",len:"
							+ data.length + "</font>");
		} else {
					var dataObj=eval("("+data+")");
					//alert(dataObj.rows.length);
					//if(dataObj.rows.length == 0) return;
					$.each(dataObj.rows,function(idx,item){ 
						//alert(item.item1+",value:"+item.item2);
						$("#msg").append("<li>item1:" + item.item1+ "&nbsp; item2:" + item.item2+ "</li>");
					});
					//alert(dataObj.rows.length);
					//alert("name:"+dataObj.rows[0].item1+",value:"+dataObj.rows[0].item2); 
					//alert("name:"+dataObj.rows[1].item1+",value:"+dataObj.rows[1].item2); 
                // $("#msg").html("<li>name:" + d.rows[0]+ "&nbsp; Age:" + d.rows[0]+ "</li>")
		}
	});
</script>
</head>
<body>
	<p>A dialog box will report the network state.</p>
	<div id="msg"></div>
</body>
</html>